package com.itheima.tlias08_14.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LoadOssConfig {

    @Resource
    AliyunOssConfig ossConfig;

    @Bean
    public OSS createOss(){
        // 指定上传的文件路径 和 accessKeyId 和 accessKeySecret。
        OSS ossClient = new
                OSSClientBuilder().
                build(ossConfig.getEndpoint(),
                        ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
        return ossClient;
    }


}
